<?php
require_once "jssdk.php";
$jssdk = new JSSDK("wx409a5223727cfbde", "3750cb321b4965883f1ccbe1fc945f8d");
$signPackage = $jssdk->GetSignPackage();
?>
<html>
<head>
    <meta charset="utf-8">
    <title>闪耀世界的苏州穹幕</title>
    <meta name="viewport" content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"/>
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta name="full-screen" content="true"/>
    <meta name="screen-orientation" content="portrait"/>
    <meta name="x5-fullscreen" content="true"/>
    <meta name="360-fullscreen" content="true"/>
    <style>
        html, body {
            -ms-touch-action: none;
            background: #888888;
            padding: 0;
            border: 0;
            margin: 0;
            height: 100%;
        }
    </style>

    <!--这个标签为通过egret提供的第三方库的方式生成的 javascript 文件。删除 modules_files 标签后，库文件加载列表将不会变化，请谨慎操作！-->
    <!--modules_files_start-->
	<script egret="lib" src="libs/modules/egret/egret.min.js"></script>
	<script egret="lib" src="libs/modules/egret/egret.web.min.js"></script>
	<script egret="lib" src="libs/modules/game/game.min.js"></script>
	<script egret="lib" src="libs/modules/res/res.min.js"></script>
	<script egret="lib" src="libs/modules/tween/tween.min.js"></script>
	<!--modules_files_end-->

    <!--这个标签为不通过egret提供的第三方库的方式使用的 javascript 文件，请将这些文件放在libs下，但不要放在modules下面。-->
    <!--other_libs_files_start-->
    <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
     <script src="libs/three.js"></script>
    <script src="libs/three.js"></script>
		<script src="libs/Detector.js"></script>
        <script src="libs/Tween.js"></script>
		<script id="vertexShader" type="x-shader/x-vertex">

			/**
			* Example Vertex Shader
			* Sets the position of the vertex by setting gl_Position
			*/

			// Set the precision for data types used in this shader
			precision highp float;
			precision highp int;

			// Default THREE.js uniforms available to both fragment and vertex shader


			// Default uniforms provided by ShaderFrog.
			uniform float time;

			// Default attributes provided by THREE.js. Attributes are only available in the
			// vertex shader. You can pass them to the fragment shader using varyings
			attribute vec2 uv2;

			// Examples of variables passed from vertex to fragment shader
			varying vec3 vPosition;
			varying vec3 vNormal;
			varying vec2 vUv;
			varying vec2 vUv2;

			void main() {
			// To pass variables to the fragment shader, you assign them here in the
			// main function. Traditionally you name the varying with vAttributeName
			vNormal = normal;
			vUv = uv;
			vUv2 = uv2;
			vPosition = position;

			// This sets the position of the vertex in 3d space. The correct math is
			// provided below to take into account camera and object data.
			gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
			}
		</script>
		<script id="fragmentShader" type="x-shader/x-fragment">
            // console.log('hahahahahah!!!!!!!!!!!!!')
			precision highp float;
			precision highp int;
			uniform sampler2D iChannel0;
			uniform vec2 resolution;
			uniform float time;
			uniform float angle;
			varying vec2 vUv;
			const float PI = 3.141592658;
			const float TAU = 2.0 * PI;
			const float sections = 16.0;
			void main()
            {
               vec2 pos = vec2(vUv.xy - 0.5 * resolution.xy) / resolution.y;
               float rad = length(pos);
               float angle = atan(pos.y, pos.x)+angle;
               float ma = mod(angle, TAU / sections);
               ma = abs(ma - PI / sections);
               float x = cos(ma) * rad;
               float y = sin(ma) * rad;
               float time = time / 30.0;
               gl_FragColor = texture2D(iChannel0, vec2(x - time, y - time));
            }
			float Tile1D(float p, float a)
            {
                 p -= 4.0 * a * floor(p / 4.0 * a);
                 p -= 2. * max(p - 2.0 * a, 0.0);
                 return p;
             }

		</script>
		<script src='ThreeMain.js'></script>
    <!--other_libs_files_end-->

    <!--这个标签会被替换为项目中所有的 javascript 文件。删除 game_files 标签后，项目文件加载列表将不会变化，请谨慎操作！-->
    <!--game_files_start-->
	<script src="main.min.js"></script>
	<!--game_files_end-->
</head>
<body>
    <div style="display: none">
			<img src='suolue.jpg' width="400" height="400"/>
	</div>
    <audio id="sound_bg" class="media-audio" src="resource/assets/bg.mp3" autoplay='autoplay' preload="preload" loop="loop"></audio>
    <div style="z-index:1;margin: auto;width: 100%;height: 100%;" class="egret-player"
         data-entry-class="Main"
         data-orientation="landscape"
         data-scale-mode="noBorder"
         data-frame-rate="60"
         data-content-width="1136"
         data-content-height="740"
         data-show-paint-rect="false"
         data-multi-fingered="2"
         data-show-fps="false" data-show-log="false"
         data-show-fps-style="x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9">
    </div>
    <div id="container" style="z-index:0;position: absolute;left: 0px;top:0px"></div>
    <!--<img id="img_info" src="resource/assets/info.png" style="z-index:2;position: absolute;left: 0px;top:0px"/>-->
    <script>
        /**
         * {
         * "renderMode":, //引擎渲染模式，"canvas" 或者 "webgl"
         * "audioType": "" //使用的音频类型，0:默认，1:qq audio，2:web audio，3:audio
         * "antialias": //WebGL模式下是否开启抗锯齿，true:开启，false:关闭，默认为false
         * }
         **/
        wx.config({
        debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
        appId: '<?php echo $signPackage["appId"];?>',
        timestamp: '<?php echo $signPackage["timestamp"];?>',
        nonceStr: '<?php echo $signPackage["nonceStr"];?>',
        signature: '<?php echo $signPackage["signature"];?>',
        jsApiList: ['onMenuShareAppMessage','onMenuShareTimeline']
        });
        wx.ready(function () {
            wx.onMenuShareAppMessage({
                title: '闪耀世界的苏州穹幕', // 分享标题
                desc: '全球第三座天钻，绽放苏州', // 分享描述
                link: 'http://www.yixuanhudong.com/ZH/ZH_WHT/index.php', // 分享链接
                imgUrl: 'http://www.yixuanhudong.com/ZH/ZH_WHT/suolue.jpg',
                type: 'link', // 分享类型,music、video或link，不填默认为link
                success: function () {
                    alert("分享成功！");
                },
                cancel: function () {
                    // 用户取消分享后执行的回调函数
                }
            });
            wx.onMenuShareTimeline({
                title: '闪耀世界的苏州穹幕', // 分享标题
                link:  'http://www.yixuanhudong.com/ZH/ZH_WHT/index.php', // 分享链接
                imgUrl: 'http://www.yixuanhudong.com/ZH/ZH_WHT/suolue.jpg', // 分享图标
                success: function () {
                    // 用户确认分享后执行的回调函数
                },
                cancel: function () {
                    // 用户取消分享后执行的回调函数
                }
            });
            wx.error(function (res) {

                // config信息验证失败会执行error函数，如签名过期导致验证失败

            });
        });


        var audio;
        document.addEventListener("WeixinJSBridgeReady", playMusic, false);
        function playMusic() {
           audio = document.getElementById('sound_bg');
           audio.play();
        //    audio.pause();
        }
        
        function MusicOnOff(bl, id) {
            if (bl) {
                audio = document.getElementById('sound_bg')
                if (audio) {
                    audio.play();
                    audio.volume = 1;
                }

            }
            else {
                audio = document.getElementById('sound_bg')
                if (audio) {
                    audio.pause();
                    audio.volume = 0;
                }
            }
        }
        threeInit();
        egret.runEgret({renderMode:"webgl", audioType:0});
    </script>
</body>
</html>
